/**
 * Copyright &copy; 2013-2019 山东易科德软件有限公司
 * All rights reserved.
 */
package com.uniedp.modules.mdm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.uniedp.core.service.impl.CrudServiceImpl;
import com.uniedp.modules.api.dao.ApiConfDao;
import com.uniedp.modules.api.entity.ApiConfEntity;
import com.uniedp.modules.mdm.dao.MdmInventoryZp1Dao;
import com.uniedp.modules.mdm.dto.MdmInventoryZp1DTO;
import com.uniedp.modules.mdm.entity.MdmInventoryZp1Entity;
import com.uniedp.modules.mdm.service.MdmInventoryZp1Service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;

/**
 * zhouServiceImpl
 * @author zhou
 * @version 2021-09-09s
 */
@Service
public class MdmInventoryZp1ServiceImpl extends CrudServiceImpl<MdmInventoryZp1Dao, MdmInventoryZp1Entity, MdmInventoryZp1DTO> implements MdmInventoryZp1Service {

    @Override
    public QueryWrapper<MdmInventoryZp1Entity> getWrapper(Map<String, Object> params){
    QueryWrapper<MdmInventoryZp1Entity> wrapper = new QueryWrapper<>();
    String id = (String)params.get("id");
    wrapper.eq(StringUtils.isNotBlank(id), "id", id);
        Object invCode=params.get("invCode");
        if(invCode!=null){
          wrapper.like(StringUtils.isNotBlank(invCode.toString()), "INV_CODE", invCode.toString());
        }
        Object invName=params.get("invName");
        if(invName!=null){
          wrapper.like(StringUtils.isNotBlank(invName.toString()), "INV_NAME", invName.toString());
        }
        Object status=params.get("status");
        if(status!=null){
          wrapper.eq(StringUtils.isNotBlank(status.toString()), "STATUS", status.toString());
        }
        Object invType=params.get("invType");
        if(invType!=null){
          wrapper.like(StringUtils.isNotBlank(invType.toString()), "inv_type", invType.toString());
        }
        Object productionDate=params.get("productionDate");
        if(productionDate!=null){
          wrapper.like(StringUtils.isNotBlank(productionDate.toString()), "PRODUCTION_DATE", productionDate.toString());
        }
    return wrapper;
    }

    @Override
    public void action(Long[] ids) {
        for(long id :ids) {
            QueryWrapper<MdmInventoryZp1Entity> wrapper = new QueryWrapper<>();
            wrapper.eq("id", id);
            MdmInventoryZp1Entity entity = new MdmInventoryZp1Entity();
            entity.setStatus("1");
            this.baseDao.update(entity, wrapper);
        }
    }

    @Override
    public void stop(Long[] ids) {
        for (long id : ids){
            QueryWrapper<MdmInventoryZp1Entity> wrapper = new QueryWrapper<>();
            wrapper.eq("id",id);
            MdmInventoryZp1Entity entity = new MdmInventoryZp1Entity();
            entity.setStatus("0");
            this.baseDao.update(entity, wrapper);
        }
    }
}